using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Microsoft.CSharp;
using System.Runtime.Remoting.Activation;
using System.CodeDom;

using NBusiness.Utilities;
using NBusiness.Templates;
using NBusiness.CodeDom;
using NBusiness.CodeDom.Compiler;

namespace NBusiness.ESharp.Compiler
{
	internal class ESharpGenerator : EntityGenerator
	{
		/// <summary>
		/// Generates code files seperated by \relationship\n\relationship\n and writes them to the given TextWriter.
		/// </summary>
		/// <param name="Writer">The writer that will contain the generated code.</param>
		/// <param name="Families">The families to generate code from.</param>
        public override EntityResourceFile[] GenerateFilesFromFamily(EntityCompilerParameters options, EntityRoot root)
		{
            //List<ResourceFile> files = new List<ResourceFile>();

            //foreach (Family family in families)
            //{
            //    files.AddRange(Generate(family));
            //}
   
            //return files.ToArray();

            // ****
            // This was generating C# originally but should probably actually generate E#
            // This should be for doing the reverse of the compiler...
            // ****

            return null;
		}

        //private ResourceFile[] Generate(Family family)
        //{
        //    List<ResourceFile> files = new List<ResourceFile>();
        //    foreach (Family f in family.Families.Values)
        //    {
        //        files.AddRange(Generate(f));
        //    }

        //    foreach (Template t in Template.Templates.Values)
        //    {
        //        t.Warning += new EventHandler<TemplateWarningEventArgs>(template_Warning);
        //        try
        //        {
        //            files.AddRange(t.Generate());
        //            t.Warning -= new EventHandler<TemplateWarningEventArgs>(template_Warning);
        //        }
        //        catch
        //        {
        //            t.Warning -= new EventHandler<TemplateWarningEventArgs>(template_Warning);
        //            throw;
        //        }
        //    }

        //    return files.ToArray();
        //}


        public override string CreateEscapedIdentifier(string value)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public override string CreateValidIdentifier(string value)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public override void GenerateCodeFromCompileUnit(CodeCompileUnit e, TextWriter w, System.CodeDom.Compiler.CodeGeneratorOptions o)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public override void GenerateCodeFromExpression(CodeExpression e, TextWriter w, System.CodeDom.Compiler.CodeGeneratorOptions o)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public override void GenerateCodeFromNamespace(CodeNamespace e, TextWriter w, System.CodeDom.Compiler.CodeGeneratorOptions o)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public override void GenerateCodeFromStatement(CodeStatement e, TextWriter w, System.CodeDom.Compiler.CodeGeneratorOptions o)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public override void GenerateCodeFromType(CodeTypeDeclaration e, TextWriter w, System.CodeDom.Compiler.CodeGeneratorOptions o)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public override string GetTypeOutput(CodeTypeReference type)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public override bool IsValidIdentifier(string value)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public override bool Supports(System.CodeDom.Compiler.GeneratorSupport supports)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public override void ValidateIdentifier(string value)
        {
            throw new Exception("The method or operation is not implemented.");
        }
    }
}
